package com.egobuy.cms.controller;


import com.egobuy.cms.service.IContentCategoryService;
import com.egobuy.cms.service.impl.ContentCategoryServiceImpl;
import com.egobuy.entity.ContentCategory;
import com.egobuy.pojo.BuyResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;

import java.util.List;

/**
 * <p>
 * 内容分类 前端控制器
 * </p>
 *
 * @author 戴着假发的程序员
 * @since 2021-11-22
 */
@RestController
@RequestMapping("/contentCat")
@CrossOrigin(value = "*",origins = "*",allowedHeaders = "*",methods ={RequestMethod.GET,RequestMethod.POST},maxAge = 3600)
public class ContentCategoryController {
    @Autowired
    private IContentCategoryService contentCategoryService;
    @RequestMapping(value = "/save",produces = "application/json;chartset=utf-8")
    public BuyResult<ContentCategory> save(ContentCategory contentCategory){

        return contentCategoryService.saveCat(contentCategory);
    }
    @RequestMapping(value = "/edit",produces = "application/json;chartset=utf-8")
    public BuyResult<ContentCategory> edit(ContentCategory contentCategory){
        return contentCategoryService.editCat(contentCategory);
    }
    @RequestMapping(value = "/queryByParentId",produces = "application/json;charset=utf-8")
    public BuyResult<List<ContentCategory>> queryByParentId(long parentId){
        return contentCategoryService.queryByParentId(parentId);
    }
    @RequestMapping(value = "delete",produces = "application/json;charset=utf-8")
    public BuyResult delete(long id){
        return contentCategoryService.deleteCat(id);
    }

}
